﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProgNetComponentsDx.Base.Classes;
using ProgNetComponents.Validation;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.ComponentModel.Design;
using System.Drawing.Design;
using ProgNetComponents.Utils.EventHandlers;
using ProgNetComponents.Validation.Rules;

namespace ProgNetComponentsDx.Validation
{
    public class ValidationSettings : BaseSettings, IDisposable
    {
        public ValidationSettings(object target, ValidationProvider provider)
            : base(target, provider)
        {
            Rules = new ValidationRulesForTableCollection();
            _Validate = true;
        }
        
        private bool _Validate;

        [Editor(typeof(Design.ValidationRulesForTableCollectionEditor), typeof(UITypeEditor))]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [NotifyParentProperty(true)]
        public ValidationRulesForTableCollection Rules
        {
            get;
            private set;
        }

        [ProgNetComponents.Design.Attributes.AlwaysSerialize]
        public bool Validate
        {
            get { return _Validate; }
            set
            {
                _Validate = value;
                OnSettingsChanged();
            }
        }

        public void Dispose()
        {
            Rules.Dispose();
            Rules.Clear();
        }
    }

   
}

